package com.woniuxy.controller;

import com.woniuxy.entity.RbacRole;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacRoleService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 马宇航
 * @Todo: TODO
 * @DateTime: 22/09/02/0002 15:52
 * @Component: 成都蜗牛学苑
 **/
@RestController
@RequestMapping("/rbacRole")
public class RbacRoleController {
    @Autowired
    RbacRoleService rbacRoleService;
    @RequiresPermissions(logical= Logical.OR,value = {"role:list"})
    @GetMapping("/")
    public ResponseEntity findAll(){
        return rbacRoleService.findAll();
    }
    @GetMapping("/{id}")
    @RequiresPermissions({"role:findOne","admin"})
    public ResponseEntity findOne(@PathVariable("id") int id){
        return rbacRoleService.findOne(id);
    }
    @PostMapping("/")
    @RequiresPermissions({"role:addOne","admin"})
    public ResponseEntity addOne(@RequestBody RbacRole rbacRole){
        return rbacRoleService.addOne(rbacRole);
    }
    @DeleteMapping("/{id}")
    @RequiresPermissions({"role:deleteOne","admin"})
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacRoleService.deleteOne(id);
    }
    @PutMapping("/")
    public ResponseEntity updateOne(@RequestBody RbacRole rbacRole){
        return rbacRoleService.updateOne(rbacRole);
    }
}
